home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / smaltalk / manchest.lha / MANCHESTER / manchester / 4.1 / Cursor-fromString.st < prev    next >
Text File  |  1993-07-24  |  1KB  |  41 lines

  1. "    NAME        Cursor-fromString
  2.     AUTHOR        Bernard Horan <bernard@is.morgan.com>
  3.     CONTRIBUTOR    Bernard Horan <bernard@is.morgan.com>
  4.     FUNCTION      Cursor instance creation method
  5.     ST-VERSIONS    4.1
  6.     PREREQUISITES     
  7.     CONFLICTS     
  8.     DISTRIBUTION    global
  9.     VERSION        4.0
  10.     DATE        September 1992
  11.     SUMMARY        One method to create a Cursor from a (small)
  12. string. Emphasis may also be supplied. Originally written by Pieter S.
  13. van der Meulen for VI2.3, and suitably amended. BH, 25/9/92"!
  14. 'From Objectworks\Smalltalk(R), Release 4.1 of 15 April 1992 on 10 September 1992 at 3:05:04 am'!
  15.  
  16.  
  17.  
  18. !Cursor class methodsFor: 'instance creation'!
  19.  
  20. fromString: aString emphasis: aSymbol 
  21.     "Create a Cursor specified by aString. 
  22.     Be sure to keep aString small, e.g. 'S' or '2'. 
  23.     The emphasis is specified by aSymbol. 
  24.     Originally written by Pieter S. van der Meulen for VI2.3 
  25.     and subsequently amended by Bernard Horan, 10 September 1992"
  26.     "Cursor blank showWhile: [9 to: 0 by: -1 do: [:aNumber | 
  27.     (Cursor fromString: aNumber printString emphasis: #bold) 
  28.     showWhile: [(Delay forMilliseconds: 500) wait]]]"
  29.  
  30.     | image text pixmap |
  31.     text := (Text string: aString emphasis: aSymbol) asComposedText.
  32.     pixmap := Pixmap extent: 16 @ 16.
  33.     text displayOn: pixmap graphicsContext at: pixmap bounds center - text bounds center.
  34.     image := pixmap asImage convertToPalette: MappedPalette whiteBlack.
  35.     ^self
  36.         image: image
  37.         mask: (image copy palette: CoveragePalette monoMaskPalette)
  38.         hotSpot: 8 @ 8
  39.         name: 'temp'! !
  40.  
  41.